package com.jt.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jt.pojo.User;
import com.jt.util.ObjectMapperUtil;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.jt.mapper.UserMapper;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    private static Map<Integer, String> map = new HashMap<>();

    static {
        map.put(1, "username");
        map.put(2, "phone");
        map.put(3, "email");
    }

// 数出给定ID的集合
    @Override
    public boolean findAll(String param, Integer type) {
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(map.get(type), param);
        Integer i = userMapper.selectCount(queryWrapper);
        return i>0;
    }

    @Override
    public List<User> findUserList() {
      return userMapper.selectList(null);
    }
}
